﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CSharpDemo._02_对象和类型
{
    struct Dimensions
    {
       public  double Width;
       public  double Height;

        //1.默认的没有参数的构造函数不能被替换

        //2.结构的构造函数必须给每个字段都赋值
        public Dimensions( double Width , double Height)
        {
            this.Width = Width;
            this.Height = Height;
        }

        //3.结构没有继承

        //4.结构是值类型
    }

    class TestStruct
    {
        public static void Test()
        {
            //默认的构造函数
            Dimensions a = new Dimensions();
            //带有2个参数的构造函数
            Dimensions b = new Dimensions(5, 10);
            Console.WriteLine("\n测试结构");
            Console.WriteLine("Width:" + a.Width);
            Console.WriteLine("Height:" + a.Height);
        }
    }
}
